function checkForm(){
		// 校验用户名:
		// 获得用户名文本框的值:
		var username = document.getElementById("username").value;
		var span1 = document.getElementById("span1").innerText;
		if(span1.charCodeAt(3) == "已经存在".charCodeAt()){
			layer.alert('用户名已存在!',{icon: 2});

			return false;
		}
		if(username == null || username == ''){
			layer.alert('用户名不能为空!',{icon: 0});
			return false;
		}
		// 校验密码:
		// 获得密码框的值:
		var password = document.getElementById("password").value;
		if(password == null || password == ''){
			layer.alert('密码不能为空!',{icon: 0});
			return false;
		}
		// 校验确认密码:
		var repassword = document.getElementById("repassword").value;
		if(repassword != password){
			layer.alert('两次密码不一致!',{icon: 0});
			return false;
		}
	}
	
	
	function checkUsername(){

		var username = document.getElementById("username").value;
		// 1.创建异步交互对象
		var xhr = createXmlHttp();
		// 2.设置监听
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4){
				if(xhr.status == 200){
					document.getElementById("span1").innerHTML = xhr.responseText;
				}
			}
		}
		// 3.打开连接
		xhr.open("GET","${pageContext.request.contextPath}/user_findByName.action?time="+new Date().getTime()+"&username="+username,true);
		// 4.发送
		xhr.send(null);
	}
	
	function checkEmail(){
		clearMessage('espan');
		// 获得文件框值:
		var email = document.getElementById("email").value;
		// 1.创建异步交互对象
		var xhr = createXmlHttp();
		// 2.设置监听
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4){
				if(xhr.status == 200){
					document.getElementById("span2").innerHTML = xhr.responseText;
				}
			}
		}
		// 3.打开连接
		xhr.open("GET","${pageContext.request.contextPath}/user_checkEmail.action?time="+new Date().getTime()+"&email="+email,true);
		// 4.发送
		xhr.send(null);
	}
	
	
	function createXmlHttp(){
		   var xmlHttp;
		   try{ // Firefox, Opera 8.0+, Safari
		        xmlHttp=new XMLHttpRequest();
		    }
		    catch (e){
			   try{// Internet Explorer
			         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			      }
			    catch (e){
			      try{
			         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			      }
			      catch (e){}
			      }
		    }

			return xmlHttp;
		 }
	
	function change(){
		var img1 = document.getElementById("checkImg");
		img1.src="${pageContext.request.contextPath}/checkImg.action?time="+new Date().getTime();
	}
	function clearMessage(id){
		document.getElementById(id).innerHTML='';
	}
	
	
		document.onkeyup = function(e){
			 var keycode=window.event ? e.keyCode :e.which;
			if(keycode == 13){
				checkForm();
			}
		}

		
